package com.xbongbong.saas.factory.publicrule;

import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.pro.constant.I18nStringConstant;
import com.xbongbong.pro.enums.errorcodes.SystemErrorCodeEnum;
import com.xbongbong.saas.enums.CustomerRuleEnum;
import com.xbongbong.saas.enums.CustomerSeniorRuleTypeEnum;

/**
 * 公海规则校验、数据获取接口
 *
 * @author : chy
 * @version v3.22
 * @date 创建时间：2018-5-16 下午3:53:16
 */
public class OperateRuleValueFactory {


    public static IOperateRuleValue operateRuleValueFactory(Integer ruleType) throws XbbException {

        CustomerRuleEnum customerRuleEnum = CustomerRuleEnum.getByCode(ruleType);

        switch (customerRuleEnum) {
            case NO_CUSTOMER_COMMUNICATE_RULE:
                return new OperateNoCommunicateRuleValue();
            case NO_OPPORTUNITY_RULE:
                return new OperateNoOpportunityRuleValue();
            case NO_CONTRACT_RULE:
                return new OperateNoContractRuleValue();
            case MAX_CUSTOMER_NUM_RULE:
                return new OperateMaxCustomerNumRuleValue();
            case PRE_PRINCIPAL_RULE:
                return new OperatePrePrincipalRuleValue();
            case GAIN_RATE_RULE:
                return new OperateGainRateRuleValue();
            default:
                throw new XbbException(SystemErrorCodeEnum.API_ERROR_100028, I18nStringConstant.RULE_TYPE_ERROR);
        }
    }

    public static IOperateRuleValue operateSeniorRuleValueFactory(Integer ruleType) throws XbbException {

        CustomerSeniorRuleTypeEnum customerRuleEnum = CustomerSeniorRuleTypeEnum.getByCode(ruleType);

        switch (customerRuleEnum) {
            case MAX_CUSTOMER_NUM_RULE:
                return new OperateMaxCustomerNumRuleValue();
            case PRE_PRINCIPAL_RULE:
                return new OperatePrePrincipalRuleValue();
            case GAIN_RATE_RULE:
                return new OperateGainRateRuleValue();
            default:
                throw new XbbException(SystemErrorCodeEnum.API_ERROR_100028, I18nStringConstant.RULE_TYPE_ERROR);
        }
    }
}
